package filter;

import javax.servlet.*;
import java.io.IOException;

/*
    过滤器配置对象的使用
 */
//@WebFilter("/servletDemo01")
public class FilterDemo05 implements Filter {
    /*
        初始化方法
     */
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }

    /*
        提供服务的方法
     */
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("filterDemo05执行了");

        //处理乱码
        servletResponse.setContentType("text/html;charset=UTF-8");

        //放行
        filterChain.doFilter(servletRequest,servletResponse);
    }
    /*
        对象销毁
     */
    @Override
    public void destroy() {

    }
}
